package com.learn.service.impl;

import com.learn.dao.AccountDao;
import com.learn.pojo.Account;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/01/20
 * @description 隔离级别测试
 */
@Service("i1")
public class IsolateService {
    @Resource
    private AccountDao accountDao;

    @Transactional(rollbackFor = RuntimeException.class, noRollbackFor = NullPointerException.class)
    public void insert(Account account) throws IOException {
        accountDao.insert(account);
        if(1 == 1) {
            throw new RuntimeException();
        }
    }
}
